package org.jeecg.modules.dock.entity.mes.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.dock.entity.BaseResponseV0;

import java.io.Serializable;

/**
 * mes响应通用实体
 *
 * @author zhoutong
 */
@ApiModel(value = "mes响应通用实体", description = "mes响应通用实体")
@Data
@ToString(callSuper = true)
public class MesBaseResponseVO<T>  extends BaseResponseV0 implements Serializable {

    @ApiModelProperty("错误码")
    private Integer errcode;

    @ApiModelProperty("响应数据")
    private T data;

    public MesBaseResponseVO() {

    }

    public static <T> MesBaseResponseVO<T> ok(T data) {
        MesBaseResponseVO<T> r = new MesBaseResponseVO<T>();
        r.setTarget(SUCCESS);
        r.setErrcode(CommonConstant.STATUS_NORMAL);
        r.setData(data);
        r.setMsg("请求成功！");
        return r;
    }

    public static <T> MesBaseResponseVO<T> ok() {
        MesBaseResponseVO<T> r = new MesBaseResponseVO<T>();
        r.setTarget(SUCCESS);
        r.setErrcode(CommonConstant.STATUS_NORMAL);
        r.setMsg("请求成功！");
        return r;
    }

    public static <T> MesBaseResponseVO<T> failure() {
        MesBaseResponseVO<T> r = new MesBaseResponseVO<T>();
        r.setTarget(ERROR);
        r.setErrcode(CommonConstant.DEL_FLAG_1);
        r.setMsg("服务器内部错误！");
        return r;
    }

    public static <T> MesBaseResponseVO<T> failure(String message) {
        MesBaseResponseVO<T> r = new MesBaseResponseVO<T>();
        r.setTarget(ERROR);
        r.setErrcode(CommonConstant.DEL_FLAG_1);
        r.setMsg(message);
        return r;
    }


}
